<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>yukari world</title>
<#include "/lib/base_source.ftl">
<style type="text/css">
</style>
</head>
<body>
<#include "/lib/mask.ftl">
<div class='whole-container'>
<#include "/lib/header.ftl">
    <div>
        <ul class="breadcrumb">
        	<li>签到管理</li><span class="divider">/</span>
            <li>积分列表</li>
        </ul>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="container span12">
            <#include "/lib/alert.ftl">

                <div class='main-content'>
                    <div class="well form-inline">
                        <span>您的总积分: ${authScore}, 已使用积分: ${price}, 当前可用积分${authScore-price}</span><br/>
                        <span>您的签到总次数: ${total}, 其中${punctual}次准时，${late}次迟到，${absenteeism}次未到</span>
                    </div>
                    <div class="table-content">
                    <#-- table -->
                        您的签到:
                        <#if total<=0>
                        当前没有签到数据
                        <#else>
                        <div>
                            <a style="float:left" href="javascript:headShow()" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-fast-backward"></i></a>
                            <a style="float:left" href="javascript:leftShow()" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-chevron-left"></i></a>
                            <a style="float:right" href="javascript:tailShow()" class="btn btn-sm btn-info"><i class="	glyphicon glyphicon-fast-forward"></i></a>
                            <a style="float:right" href="javascript:rightShow()" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-chevron-right"></i></a>
                        </div>
                        <table class="table table-striped table-bordered table-condensed" id="registerTable" style="font-size:12px;word-break:break-all;word-wrap:break-word;">
                            <tr id="registerTimeTr">
                            <#list list as item>
                                <td>${item.registerTime}</td>
                            </#list>
                            </tr>
                            <tr id="registerStatusTr">
                            <#list list as item>
                                <td>
                                    <#if item.status == 0>
                                        <img src="${rc.contextPath}/images/qiandao_64.png" style="width:32px">
                                    <#elseif item.status == 1>
                                        <img src="${rc.contextPath}/images/chidao_32.png" style="width:16px">
                                    </#if>
                                </td>
                            </#list>
                            </tr>
                        </table>
                        </#if>
                    </div>
                    <div class="table-content">
                        <div>可兑换礼物列表<a class="btn btn-sm btn-info" style="float:right" href="${rc.contextPath}/admin/exchange/history/authList">兑换记录</a></div>

                        <table class="table table-striped table-bordered table-condensed" id="itemTable" style="font-size:12px;word-break:break-all;word-wrap:break-word;">
                            <tr>
                                <th>物品名</th>
                                <th>样图（点击放大）</th>
                                <th>兑换价格</th>
                                <th>库存</th>
                                <th>操作</th>
                            </tr>
                            <#list gfitList as item>
                                <tr>
                                    <td>${item.name}</td>
                                    <td><#if item.image != ''><a href="http://image.loveyukari.com/${item.image}"  target="_blank" ><img src="http://image.loveyukari.com/${item.image}" style="max-width: 200px;" /></a></#if></td>
                                    <td>${item.price}</td>
                                    <td>${item.num}</td>
                                    <td><a class="btn btn-sm btn-info" href="javascript:" onclick="exchangeGfit(${item.id},'${item.name}',${item.price})">兑换</a></td>
                                </tr>
                            </#list>
                        </table>
                    <#-- table -->
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

<script>

    $(document).ready(function(){
        tailShow();
    });

    function leftShow() {
        var tds = $("#registerTimeTr td:visible");
        var td = tds.first().prev();
        if (td.length != 0){
            td.show();
            tds.last().hide();
            var tds2 = $("#registerStatusTr td:visible");
            tds2.first().prev().show();
            tds2.last().hide();
        }
    }
    function rightShow(){
        var tds = $("#registerTimeTr td:visible");
        var td = tds.last().next();
        if (td.length != 0){
            td.show();
            tds.first().hide();
            var tds2 = $("#registerStatusTr td:visible");
            tds2.first().hide();
            tds2.last().next().show();
        }
    }
    function headShow(){
        $("#registerTimeTr td").hide();
        $("#registerTimeTr td:lt(10)").show();
        $("#registerStatusTr td").hide();
        $("#registerStatusTr td:lt(10)").show();
    }

    function tailShow(){
        $("#registerTimeTr td").hide();
        $("#registerTimeTr td:gt(${total-11})").show();
        $("#registerStatusTr td").hide();
        $("#registerStatusTr td:gt(${total-11})").show();
    }


    function exchangeGfit(id,name,price){
        var txt = "兑换 "+name+" , 价格 "+price+" 积分, 是否确定？";
        if (confirm(txt)){
            $.ajax({
                url : "${rc.contextPath}/admin/exchange/gfit",
                dataType : "json",
                data :  {"gfitId":id},
                type:'post',
                success:function(json){
                    if (json.code == 0){
                        location.href = "${rc.contextPath}/admin/exchange/history/authList";
                    } else {
                        alert("添加失败: "+json.message);
                    }
                }
            });
        }
    }
	    


</script>
</body>
</html>